-
-
Notifications
You must be signed in to change notification settings - Fork 614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slots in core #5775
Slots in core #5775
Conversation
✅ Deploy Preview for plone-components canceled.
|
✅ Deploy Preview for volto ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked a few questions, too, so these suggestions will need to be reviewed as onesies.
Co-authored-by: Steve Piercy <[email protected]>
Co-authored-by: Steve Piercy <[email protected]>
@@ -244,13 +245,15 @@ class View extends Component { | |||
: null | |||
} | |||
/> | |||
<SlotRenderer name="aboveContent" content={this.props.content} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plone/volto-team would be interesting to hear what other slots you think should be added.
I am thinking of plone 4 viewlets managers that we had, if we need to add something to the header
and footer as well or we keep it simple for starters and add extra slots as needed.
So for sure I am hoping that others also give feedback on this work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would for sure like to have built-in slots above and below the title in the title block.
Header and footer also makes sense conceptually...but then I guess we should move the existing rendering of these into slots, which is probably hard to do without it becoming a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should include a list of the built-in slots in the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davisagli I've thought about the above and below title too. However, there's a couple of drawbacks, eg. How about the edit mode? Should they appear too there? How about if you move the title block around? Unlikely, but possible. But I agree that they will solve more problems than bring.
In fact, the aboveContentTitle
in Volto is always the aboveContent
to be safe. Probably in classic made much more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the default slots available.
@sneridagh I significantly overhauled the Anatomy section, per our conversation yesterday. There are a couple of missing pieces, as noted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stevepiercy Thanks, I think the rewritten Anatomy section is clearer.
… for predicate helpers
…ead), write (update), delete.
docs/source/configuration/slots.md
Outdated
``` | ||
|
||
When the slot components with the same name and component under a given slot have all of their predicates return `true`, then that component will render in the slot. | ||
Else, if there are slot components with the same name, but with a different component, and without predicates, then that different component will render. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not accurate, at least how I understand it by reading it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The below example is cocrrect though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the component
doesn't have any effect on which SlotComponent is chosen; it's only used for rendering after the right SlotComponent is chosen.
For each name, the algorithm picks the first SlotComponent with predicates that return true (or no predicates), and its component
will be rendered. There's nothing looking for all predicates from SlotComponents with the same component
.
docs/source/configuration/slots.md
Outdated
``` | ||
|
||
When the slot components with the same name and component under a given slot have all of their predicates return `true`, then that component will render in the slot. | ||
Else, if there are slot components with the same name, but with a different component, and without predicates, then that different component will render. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the component
doesn't have any effect on which SlotComponent is chosen; it's only used for rendering after the right SlotComponent is chosen.
For each name, the algorithm picks the first SlotComponent with predicates that return true (or no predicates), and its component
will be rendered. There's nothing looking for all predicates from SlotComponents with the same component
.
docs/source/configuration/slots.md
Outdated
|
||
Thus the example slot renderer will have the following behavior. | ||
|
||
- When both a user visits the route beginning with `/de/about`, and the content type is either a Document or News Item, then the component `PageHeader` will render in the `aboveContent` slot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. PageHeader will be used if the route starts with /de/about
OR if the content type is Document or News Item. Matching either condition is sufficient; they don't have to both be true.
docs/source/configuration/slots.md
Outdated
Thus the example slot renderer will have the following behavior. | ||
|
||
- When both a user visits the route beginning with `/de/about`, and the content type is either a Document or News Item, then the component `PageHeader` will render in the `aboveContent` slot. | ||
- When one or both of the predicates are false, then the component `DefaultHeader` will render in the `aboveContent` slot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The SlotComponent with no predicates is only used if all predicates return false.
@stevepiercy let's go together this morning through all of it and let's fix the inconsistencies, I'd like to merge it asap. |
@davisagli waiting for your last input before merging! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stevepiercy @sneridagh Thanks, the docs look ok to me now
Thanks everybody for the effort on making this a reality, years in the making, I think it's one of the best additions in the last years to Volto (and not only just Volto, the feature it's on And it shouldn't end here, the persistent slots that @tiberiuichim worked on some years ago is still relevant and valuable, and it's there to resurrect when we are ready to do so. |
* main: Slots in core (#5775)
Let's see if we finally make this happen, at least the "static" ones.